function Stack() {
  this.items = [];
}

// 添加元素方法
Stack.prototype.push = function (element) {
  this.items.push(element);
};

// 移除栈顶元素
Stack.prototype.pop = function (element) {
  this.items.pop();
};

// 拿栈顶元素
Stack.prototype.peek = function () {
  return this.items[this.items.length - 1];
};

// 判断是否为空
Stack.prototype.isEmpty = function () {
  return this.items.length === 0;
};

// 清除栈
Stack.prototype.clear = function () {
  this.items = [];
};

const stack = new Stack();
stack.push({ number: 1 });
stack.push({ number: 2 });
stack.push({ number: 3 });
stack.push({ number: 4 });
stack.push({ number: 5 });
stack.push({ number: 6 });
console.log(stack);

stack.pop();

const peek = stack.peek();
stack.clear();
const empty = stack.isEmpty();
console.log(empty);
